import java.util.Scanner;

public class Test6 {
    public static void  move(char pos1,char pos2){
        System.out.println(pos1 + "->" + pos2);
    }
    public static void Hanoi(int n,char pos1,char pos2,char pos3){
        if(n==1){
            move(pos1,pos3);
        }else {
            Hanoi(n-1,pos1,pos3,pos2);
            move(pos1,pos3);
            Hanoi(n-1,pos2,pos1,pos3);
        }
    }
    public static void main(String[] args){//汉诺塔
        /*  N为盘子个数
        pos1为起始位置
        pos2为中转位置
        pos3为目的位置
         */
        Hanoi(3,'A','B','C');
    }
    public static int ret(int x){
        if(x==1)
            return 1;
        else
            return x * ret(x-1);
    }
    public static void main6(String[] args) {
        System.out.println(ret(5));
    }
    public static int getMax(int x,int y){//求两个整数的最大值
        return Math.max(x,y);
    }
    public static double getMax(double x,double y,double z){//求三个小数的最大值
        if(z > x && z > y){
            return z;
        }
        else
            return Math.max(x,y);
    }
    public static void main5(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(getMax(a, b));
        double x = 5.4;
        double y = 6.8;
        double z = 7.3;
        System.out.println(getMax(x, y, z));
    }
    public static int add(int a,int b){//两个整数相加
        return a+b;
    }
    public static double add(double a,double b,double c){//三个小数相加
        return a+b+c;
    }
    public static void main4(String[] args) {
        int x = 10;
        int y = 20;
        System.out.println(add(x, y));
        double a = 5.4;
        double b = 6.5;
        double c = 7.3;
        System.out.println(add(a, b, c));
    }
    public static int fib(int n){
        int f1 = 0;
        int f2 = 1;
        int f3 = -1;
        if(n==1)
            return 0;
        else if(n==2)
            return 1;
        else if(n > 2){
            for (int i = 1; i <= n ; i++) {
                f3 = f1+f2;
                f1 = f2;
                f2 = f3;
            }
        }
        return f3;
    }
    public static void main3(String[] args) {

        System.out.println(fib(40));
    }
    public static int fac(int n){//计算阶乘
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }return ret;
    }
    public static int facSum(int n){//计算阶乘的和
        int sum = 0;        //定义一个计数器
        for (int i = 1; i <= n; i++) {
            sum += fac(i);  //将每个数的阶乘相加
        }return sum;
    }
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){            //实现多组输入
        int x = scanner.nextInt();
        //输出
            System.out.println(fac(x));//阶乘
            System.out.println(facSum(x));//阶乘之和
        }
    }
    public static int max2(int x,int y){
        //比较两个数的大小
        return Math.max(x,y);
    }
    public static int max3(int x,int y,int z){
        //比较三个数的大小
        if(z>x&&z>y)
            return z;
        else
            return max2(x,y);
    }
    public static void main1(String[] args) {
        int m = 20;
        int n = 30;
        int t = 50;
        System.out.println(max2(m, n));
        System.out.println(max3(m, n, t));;
    }
}
